LibreOffice Module framework (master) 1
titlehelper.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#ifndef INCLUDED_FRAMEWORK_TITLEHELPER_HXX
21#define INCLUDED_FRAMEWORK_TITLEHELPER_HXX
22
23#include <com/sun/star/uno/Reference.hxx>
24#include <com/sun/star/frame/XTitle.hpp>
25#include <com/sun/star/frame/XTitleChangeBroadcaster.hpp>
26#include <com/sun/star/frame/XFrameActionListener.hpp>
27#include <com/sun/star/document/XDocumentEventListener.hpp>
28
33
34#include <rtl/ustrbuf.hxx>
35
36#include <framework/fwkdllapi.h>
37
38namespace com::sun::star::frame { class XController; }
39namespace com::sun::star::frame { class XFrame; }
40namespace com::sun::star::frame { class XModel3; }
41namespace com::sun::star::frame { class XUntitledNumbers; }
42namespace com::sun::star::uno { class XComponentContext; }
43namespace com::sun::star::uno { class XInterface; }
44
45
46namespace framework{
47
48
54 , public ::cppu::WeakImplHelper< css::frame::XTitle ,
55 css::frame::XTitleChangeBroadcaster,
56 css::frame::XTitleChangeListener ,
57 css::frame::XFrameActionListener ,
58 css::document::XDocumentEventListener >
59{
60
61 // interface
62 public:
63
64
78 TitleHelper(css::uno::Reference< css::uno::XComponentContext > xContext,
79 const css::uno::Reference< css::uno::XInterface >& xOwner,
80 const css::uno::Reference< css::frame::XUntitledNumbers >& xNumbers);
81
84 virtual ~TitleHelper() override;
85
86
88 virtual OUString SAL_CALL getTitle() override;
89
90
92 virtual void SAL_CALL setTitle(const OUString& sTitle) override;
93
94
96 virtual void SAL_CALL addTitleChangeListener(const css::uno::Reference< css::frame::XTitleChangeListener >& xListener) override;
97
98
100 virtual void SAL_CALL removeTitleChangeListener(const css::uno::Reference< css::frame::XTitleChangeListener >& xListener) override;
101
102
104 virtual void SAL_CALL titleChanged(const css::frame::TitleChangedEvent& aEvent) override;
105
106
108 virtual void SAL_CALL documentEventOccured(const css::document::DocumentEvent& aEvent) override;
109
110
112 virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent) override;
113
114
116 virtual void SAL_CALL frameAction(const css::frame::FrameActionEvent& aEvent) override;
117
118
119 // internal
120 private:
121
122 void impl_sendTitleChangedEvent ();
123
124 void impl_updateTitle (bool init = false);
125 void impl_updateTitleForModel (const css::uno::Reference< css::frame::XModel3 >& xModel, bool init);
126 void impl_updateTitleForController (const css::uno::Reference< css::frame::XController >& xController, bool init);
127 void impl_updateTitleForFrame (const css::uno::Reference< css::frame::XFrame >& xFrame, bool init);
128
129 void impl_startListeningForModel (const css::uno::Reference< css::frame::XModel >& xModel);
130 void impl_startListeningForController (const css::uno::Reference< css::frame::XController >& xController);
131 void impl_startListeningForFrame (const css::uno::Reference< css::frame::XFrame >& xFrame);
132 void impl_updateListeningForFrame (const css::uno::Reference< css::frame::XFrame >& xFrame);
133
134 void impl_appendComponentTitle ( OUStringBuffer& sTitle ,
135 const css::uno::Reference< css::uno::XInterface >& xComponent);
136 void impl_appendProductName (OUStringBuffer& sTitle);
137 void impl_appendModuleName (OUStringBuffer& sTitle);
138 void impl_appendDebugVersion (OUStringBuffer& sTitle);
139 void impl_appendSafeMode (OUStringBuffer& sTitle);
140
141 void impl_setSubTitle (const css::uno::Reference< css::frame::XTitle >& xSubTitle);
142
143 OUString impl_convertURL2Title(std::u16string_view sURL);
144
145
146 // member
147 private:
148
150 css::uno::Reference< css::uno::XComponentContext> m_xContext;
151
153 css::uno::WeakReference< css::uno::XInterface > m_xOwner;
154
156 css::uno::WeakReference< css::frame::XUntitledNumbers > m_xUntitledNumbers;
157
159 css::uno::WeakReference< css::frame::XTitle > m_xSubTitle;
160
166
168 OUString m_sTitle;
169
171 ::sal_Int32 m_nLeasedNumber;
172
175};
176
177} // namespace framework
178
179#endif // INCLUDED_FRAMEWORK_TITLEHELPER_HXX
180
181/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
AnyEventRef aEvent
FILE * init(int, char **)
can be used as implementation helper of interface css.frame.XTitle
Definition: titlehelper.hxx:59
comphelper::OMultiTypeInterfaceContainerHelper2 m_aListener
contains all title change listener
::sal_Int32 m_nLeasedNumber
knows the leased number which must be used for untitled components.
css::uno::Reference< css::uno::XComponentContext > m_xContext
points to the global uno service manager.
bool m_bExternalTitle
if it's set to sal_True the member m_sTitle has not to be changed internally.
css::uno::WeakReference< css::frame::XTitle > m_xSubTitle
provides parts of our own title and we listen there for changes too.
css::uno::WeakReference< css::uno::XInterface > m_xOwner
reference to the outside UNO class using this helper.
css::uno::WeakReference< css::frame::XUntitledNumbers > m_xUntitledNumbers
used to know how an "Untitled X" string can be created right :-)
OUString m_sTitle
the actual title value
#define FWK_DLLPUBLIC
Definition: fwkdllapi.h:19
std::u16string_view getTitle(std::u16string_view aPath)
Reference< XController > xController
Reference< XFrame > xFrame
Reference< XModel > xModel