xref: /trunk/main/sd/source/ui/accessibility/AccessiblePresentationShape.cxx (revision 45c5a00162811bd03b87fcb4fe9996782f2b59ec)
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 
44 AccessiblePresentationShape::AccessiblePresentationShape (
45     const AccessibleShapeInfo& rShapeInfo,
46     const AccessibleShapeTreeInfo& rShapeTreeInfo)
47     : AccessibleShape (rShapeInfo, rShapeTreeInfo)
48 {
49 }
50 
51 
52 
53 
54 AccessiblePresentationShape::~AccessiblePresentationShape (void)
55 {
56 }
57 
58 
59 
60 
61 //=====  XServiceInfo  ========================================================
62 
63 ::rtl::OUString SAL_CALL
64     AccessiblePresentationShape::getImplementationName (void)
65 {
66     return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessiblePresentationShape"));
67 }
68 
69 
70 
71 
72 /// Set this object's name if is different to the current name.
73 ::rtl::OUString
74     AccessiblePresentationShape::CreateAccessibleBaseName (void)
75 {
76     ::rtl::OUString sName;
77 
78     ShapeTypeId nShapeType = ShapeTypeHandler::Instance().GetTypeId (mxShape);
79     switch (nShapeType)
80     {
81         case PRESENTATION_TITLE:
82             sName = ::rtl::OUString (String(SdResId(SID_SD_A11Y_P_TITLE_N)));
83             break;
84         case PRESENTATION_OUTLINER:
85             sName = ::rtl::OUString (String(SdResId(SID_SD_A11Y_P_OUTLINER_N)));
86             break;
87         case PRESENTATION_SUBTITLE:
88             sName = ::rtl::OUString (String(SdResId(SID_SD_A11Y_P_SUBTITLE_N)));
89             break;
90         case PRESENTATION_PAGE:
91             sName = ::rtl::OUString (String(SdResId(SID_SD_A11Y_P_PAGE_N)));
92             break;
93         case PRESENTATION_NOTES:
94             sName = ::rtl::OUString (String(SdResId(SID_SD_A11Y_P_NOTES_N)));
95             break;
96         case PRESENTATION_HANDOUT:
97             sName = ::rtl::OUString (String(SdResId(SID_SD_A11Y_P_HANDOUT_N)));
98             break;
99         case PRESENTATION_HEADER:
100         sName = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_HEADER_N)) );
101             break;
102         case PRESENTATION_FOOTER:
103         sName = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_FOOTER_N)) );
104             break;
105         case PRESENTATION_DATETIME:
106         sName = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_DATE_N)) );
107             break;
108         case PRESENTATION_PAGENUMBER:
109         sName = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_NUMBER_N)) );
110             break;
111         default:
112             sName = ::rtl::OUString (String(SdResId(SID_SD_A11Y_P_UNKNOWN_N)));
113             uno::Reference<drawing::XShapeDescriptor> xDescriptor (mxShape, uno::UNO_QUERY);
114             if (xDescriptor.is())
115                 sName += ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM(": "))
116                     + xDescriptor->getShapeType();
117     }
118 
119     return sName;
120 }
121 
122 
123 
124 
125 ::rtl::OUString
126     AccessiblePresentationShape::CreateAccessibleDescription (void)
127 {
128     //    return createAccessibleName ();
129     ::rtl::OUString sDescription;
130     DescriptionGenerator aDG (mxShape);
131     ShapeTypeId nShapeType = ShapeTypeHandler::Instance().GetTypeId (mxShape);
132     switch (nShapeType)
133     {
134         case PRESENTATION_TITLE:
135         sDescription = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_TITLE_D)) );
136         aDG.Initialize (sDescription);
137             break;
138         case PRESENTATION_OUTLINER:
139         sDescription = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_OUTLINER_D)) );
140         aDG.Initialize (sDescription);              //PresentationOutlinerShape
141             break;
142         case PRESENTATION_SUBTITLE:
143             aDG.Initialize (::rtl::OUString::createFromAscii ("PresentationSubtitleShape"));
144         sDescription = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_SUBTITLE_D)) );
145         aDG.Initialize (sDescription);              //PresentationSubtitleShape
146             break;
147         case PRESENTATION_PAGE:
148             aDG.Initialize (::rtl::OUString::createFromAscii ("PresentationPageShape"));
149             sDescription = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_PAGE_D)) );
150         aDG.Initialize (sDescription);              //PresentationPageShape
151             break;
152         case PRESENTATION_NOTES:
153             aDG.Initialize (::rtl::OUString::createFromAscii ("PresentationNotesShape"));
154         sDescription = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_NOTES_D)) );
155         aDG.Initialize (sDescription);              //PresentationNotesShape
156             break;
157         case PRESENTATION_HANDOUT:
158             aDG.Initialize (::rtl::OUString::createFromAscii ("PresentationHandoutShape"));
159         sDescription = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_HANDOUT_D)) );
160         aDG.Initialize (sDescription);              //PresentationHandoutShape
161             break;
162         case PRESENTATION_HEADER:
163         sDescription = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_HEADER_D)) );
164         aDG.Initialize (sDescription);              //PresentationHeaderShape
165             break;
166         case PRESENTATION_FOOTER:
167         sDescription = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_FOOTER_D)) );
168         aDG.Initialize (sDescription);              //PresentationFooterShape
169             break;
170         case PRESENTATION_DATETIME:
171         sDescription = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_DATE_D)) );
172         aDG.Initialize (sDescription);              //PresentationDateShape
173             break;
174         case PRESENTATION_PAGENUMBER:
175         sDescription = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_NUMBER_D)) );
176         aDG.Initialize (sDescription);              //PresentationNumberShape
177             break;
178         default:
179         sDescription = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_UNKNOWN_D)) );
180         aDG.Initialize (sDescription);              //Unknown accessible presentation shape
181             uno::Reference<drawing::XShapeDescriptor> xDescriptor (mxShape, uno::UNO_QUERY);
182             if (xDescriptor.is())
183             {
184                 aDG.AppendString (::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("service name=")));
185                 aDG.AppendString (xDescriptor->getShapeType());
186             }
187     }
188 
189     return aDG();
190 }
191 ::rtl::OUString AccessiblePresentationShape::GetStyle()
192 {
193     ::rtl::OUString sName;
194 
195     ShapeTypeId nShapeType = ShapeTypeHandler::Instance().GetTypeId (mxShape);
196     switch (nShapeType)
197     {
198         case PRESENTATION_TITLE:
199             sName = ::rtl::OUString (String(SdResId(SID_SD_A11Y_P_TITLE_N_STYLE)));
200             break;
201         case PRESENTATION_OUTLINER:
202             sName = ::rtl::OUString (String(SdResId(SID_SD_A11Y_P_OUTLINER_N_STYLE)));
203             break;
204         case PRESENTATION_SUBTITLE:
205             sName = ::rtl::OUString (String(SdResId(SID_SD_A11Y_P_SUBTITLE_N_STYLE)));
206             break;
207         case PRESENTATION_PAGE:
208             sName = ::rtl::OUString (String(SdResId(SID_SD_A11Y_P_PAGE_N_STYLE)));
209             break;
210         case PRESENTATION_NOTES:
211             sName = ::rtl::OUString (String(SdResId(SID_SD_A11Y_P_NOTES_N_STYLE)));
212             break;
213         case PRESENTATION_HANDOUT:
214             sName = ::rtl::OUString (String(SdResId(SID_SD_A11Y_P_HANDOUT_N_STYLE)));
215             break;
216         case PRESENTATION_FOOTER:
217         sName = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_FOOTER_N_STYLE)) );
218             break;
219     case PRESENTATION_HEADER:
220         sName = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_HEADER_N_STYLE)) );
221             break;
222         case PRESENTATION_DATETIME:
223             sName = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_DATE_N_STYLE)) );
224             break;
225         case PRESENTATION_PAGENUMBER:
226             sName = ::rtl::OUString ( String(SdResId(SID_SD_A11Y_P_NUMBER_N_STYLE)) );
227             break;
228         default:
229             sName = ::rtl::OUString (String(SdResId(SID_SD_A11Y_P_UNKNOWN_N_STYLE)));
230             uno::Reference<drawing::XShapeDescriptor> xDescriptor (mxShape, uno::UNO_QUERY);
231             if (xDescriptor.is())
232                 sName += ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM(": "))
233                     + xDescriptor->getShapeType();
234     }
235 
236     return sName;
237 
238 }
239 } // end of namespace accessibility
240