1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 #include "AccessiblePresentationShape.hxx"
27 
28 #include "SdShapeTypes.hxx"
29 
30 #include "accessibility.hrc"
31 #include "sdresid.hxx"
32 #include <tools/string.hxx>
33 #include <svx/DescriptionGenerator.hxx>
34 #include <rtl/ustring.h>
35 
36 using namespace ::rtl;
37 using namespace ::com::sun::star;
38 using namespace	::com::sun::star::accessibility;
39 
40 namespace accessibility {
41 
42 //=====  internal  ============================================================
43 
AccessiblePresentationShape(const AccessibleShapeInfo & rShapeInfo,const AccessibleShapeTreeInfo & rShapeTreeInfo)44 AccessiblePresentationShape::AccessiblePresentationShape (
45     const AccessibleShapeInfo& rShapeInfo,
46     const AccessibleShapeTreeInfo& rShapeTreeInfo)
47     : AccessibleShape (rShapeInfo, rShapeTreeInfo)
48 {
49 }
50 
51 
52 
53 
~AccessiblePresentationShape(void)54 AccessiblePresentationShape::~AccessiblePresentationShape (void)
55 {
56 }
57 
58 
59 
60 
61 //=====  XServiceInfo  ========================================================
62 
63 ::rtl::OUString SAL_CALL
getImplementationName(void)64     AccessiblePresentationShape::getImplementationName (void)
65     throw (::com::sun::star::uno::RuntimeException)
66 {
67 	return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessiblePresentationShape"));
68 }
69 
70 
71 
72 
73 ///	Set this object's name if is different to the current name.
74 ::rtl::OUString
CreateAccessibleBaseName(void)75     AccessiblePresentationShape::CreateAccessibleBaseName (void)
76     throw (::com::sun::star::uno::RuntimeException)
77 {
78     ::rtl::OUString sName;
79 
80     ShapeTypeId nShapeType = ShapeTypeHandler::Instance().GetTypeId (mxShape);
81     switch (nShapeType)
82     {
83         case PRESENTATION_TITLE:
84             sName = ::rtl::OUString (String(SdResId(SID_SD_A11Y_P_TITLE_N)));
85             break;
86         case PRESENTATION_OUTLINER:
87             sName = ::rtl::OUString (String(SdResId(SID_SD_A11Y_P_OUTLINER_N)));
88             break;
89         case PRESENTATION_SUBTITLE:
90             sName = ::rtl::OUString (String(SdResId(SID_SD_A11Y_P_SUBTITLE_N)));
91             break;
92         case PRESENTATION_PAGE:
93             sName = ::rtl::OUString (String(SdResId(SID_SD_A11Y_P_PAGE_N)));
94             break;
95         case PRESENTATION_NOTES:
96             sName = ::rtl::OUString (String(SdResId(SID_SD_A11Y_P_NOTES_N)));
97             break;
98         case PRESENTATION_HANDOUT:
99             sName = ::rtl::OUString (String(SdResId(SID_SD_A11Y_P_HANDOUT_N)));
100             break;
101 		case PRESENTATION_HEADER:
102 	    sName = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_HEADER_N)) );
103             break;
104 		case PRESENTATION_FOOTER:
105 	    sName = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_FOOTER_N)) );
106             break;
107 		case PRESENTATION_DATETIME:
108 	    sName = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_DATE_N)) );
109             break;
110 		case PRESENTATION_PAGENUMBER:
111 	    sName = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_NUMBER_N)) );
112             break;
113         default:
114             sName = ::rtl::OUString (String(SdResId(SID_SD_A11Y_P_UNKNOWN_N)));
115             uno::Reference<drawing::XShapeDescriptor> xDescriptor (mxShape, uno::UNO_QUERY);
116             if (xDescriptor.is())
117                 sName += ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM(": "))
118                     + xDescriptor->getShapeType();
119     }
120 
121     return sName;
122 }
123 
124 
125 
126 
127 ::rtl::OUString
CreateAccessibleDescription(void)128     AccessiblePresentationShape::CreateAccessibleDescription (void)
129     throw (::com::sun::star::uno::RuntimeException)
130 {
131     //    return createAccessibleName ();
132     ::rtl::OUString sDescription;
133     DescriptionGenerator aDG (mxShape);
134     ShapeTypeId nShapeType = ShapeTypeHandler::Instance().GetTypeId (mxShape);
135     switch (nShapeType)
136     {
137         case PRESENTATION_TITLE:
138 	    sDescription = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_TITLE_D)) );
139 	    aDG.Initialize (sDescription);
140             break;
141         case PRESENTATION_OUTLINER:
142 	    sDescription = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_OUTLINER_D)) );
143 	    aDG.Initialize (sDescription);				//PresentationOutlinerShape
144             break;
145         case PRESENTATION_SUBTITLE:
146             aDG.Initialize (::rtl::OUString::createFromAscii ("PresentationSubtitleShape"));
147  	    sDescription = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_SUBTITLE_D)) );
148 	    aDG.Initialize (sDescription);				//PresentationSubtitleShape
149             break;
150         case PRESENTATION_PAGE:
151             aDG.Initialize (::rtl::OUString::createFromAscii ("PresentationPageShape"));
152             sDescription = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_PAGE_D)) );
153 	    aDG.Initialize (sDescription);				//PresentationPageShape
154             break;
155         case PRESENTATION_NOTES:
156             aDG.Initialize (::rtl::OUString::createFromAscii ("PresentationNotesShape"));
157 	    sDescription = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_NOTES_D)) );
158 	    aDG.Initialize (sDescription);				//PresentationNotesShape
159             break;
160         case PRESENTATION_HANDOUT:
161             aDG.Initialize (::rtl::OUString::createFromAscii ("PresentationHandoutShape"));
162 	    sDescription = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_HANDOUT_D)) );
163 	    aDG.Initialize (sDescription);				//PresentationHandoutShape
164             break;
165 		case PRESENTATION_HEADER:
166 	    sDescription = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_HEADER_D)) );
167 	    aDG.Initialize (sDescription);				//PresentationHeaderShape
168             break;
169 		case PRESENTATION_FOOTER:
170 	    sDescription = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_FOOTER_D)) );
171 	    aDG.Initialize (sDescription);				//PresentationFooterShape
172             break;
173 		case PRESENTATION_DATETIME:
174 	    sDescription = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_DATE_D)) );
175 	    aDG.Initialize (sDescription);				//PresentationDateShape
176             break;
177 		case PRESENTATION_PAGENUMBER:
178 	    sDescription = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_NUMBER_D)) );
179 	    aDG.Initialize (sDescription);				//PresentationNumberShape
180             break;
181         default:
182 	    sDescription = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_UNKNOWN_D)) );
183 	    aDG.Initialize (sDescription);				//Unknown accessible presentation shape
184             uno::Reference<drawing::XShapeDescriptor> xDescriptor (mxShape, uno::UNO_QUERY);
185             if (xDescriptor.is())
186             {
187                 aDG.AppendString (::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("service name=")));
188                 aDG.AppendString (xDescriptor->getShapeType());
189             }
190     }
191 
192     return aDG();
193 }
GetStyle()194 ::rtl::OUString AccessiblePresentationShape::GetStyle()
195 {
196     ::rtl::OUString sName;
197 
198     ShapeTypeId nShapeType = ShapeTypeHandler::Instance().GetTypeId (mxShape);
199     switch (nShapeType)
200     {
201         case PRESENTATION_TITLE:
202             sName = ::rtl::OUString (String(SdResId(SID_SD_A11Y_P_TITLE_N_STYLE)));
203             break;
204         case PRESENTATION_OUTLINER:
205             sName = ::rtl::OUString (String(SdResId(SID_SD_A11Y_P_OUTLINER_N_STYLE)));
206             break;
207         case PRESENTATION_SUBTITLE:
208             sName = ::rtl::OUString (String(SdResId(SID_SD_A11Y_P_SUBTITLE_N_STYLE)));
209             break;
210         case PRESENTATION_PAGE:
211             sName = ::rtl::OUString (String(SdResId(SID_SD_A11Y_P_PAGE_N_STYLE)));
212             break;
213         case PRESENTATION_NOTES:
214             sName = ::rtl::OUString (String(SdResId(SID_SD_A11Y_P_NOTES_N_STYLE)));
215             break;
216         case PRESENTATION_HANDOUT:
217             sName = ::rtl::OUString (String(SdResId(SID_SD_A11Y_P_HANDOUT_N_STYLE)));
218             break;
219         case PRESENTATION_FOOTER:
220 		sName = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_FOOTER_N_STYLE)) );
221             break;
222 	case PRESENTATION_HEADER:
223 		sName = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_HEADER_N_STYLE)) );
224             break;
225         case PRESENTATION_DATETIME:
226 			sName = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_DATE_N_STYLE)) );
227             break;
228         case PRESENTATION_PAGENUMBER:
229 			sName = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_NUMBER_N_STYLE)) );
230             break;
231         default:
232             sName = ::rtl::OUString (String(SdResId(SID_SD_A11Y_P_UNKNOWN_N_STYLE)));
233             uno::Reference<drawing::XShapeDescriptor> xDescriptor (mxShape, uno::UNO_QUERY);
234             if (xDescriptor.is())
235                 sName += ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM(": "))
236                     + xDescriptor->getShapeType();
237     }
238 
239     return sName;
240 
241 }
242 } // end of namespace accessibility
243